package moxl.dom.raw;

import static org.junit.Assert.assertTrue;

import java.util.HashSet;
import java.util.Set;

import moxl.dom.MoxlNode;
import moxl.dom.MoxlNodeVisitor;

public class MockNodeVisitor implements MoxlNodeVisitor
{
	private Set<MoxlNode> expectedStartNodes = new HashSet<MoxlNode>();
	private Set<MoxlNode> expectedEndNodes = new HashSet<MoxlNode>();

	public void endNode(MoxlNode node)
	{
		if (expectedEndNodes.contains(node))
		{
			expectedEndNodes.remove(node);
		}
	}

	public void startNode(MoxlNode node)
	{
		if (expectedStartNodes.contains(node))
		{
			expectedStartNodes.remove(node);
		}
	}

	public void expectStartNode(MoxlNode node)
	{
		expectedStartNodes.add(node);
	}

	public void verify()
	{
		assertTrue(expectedStartNodes.isEmpty() && expectedEndNodes.isEmpty());
	}

	public void expectEndNode(MoxlNode node)
	{
		expectedEndNodes.add(node);
	}

}
